package world.square;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.math.BigDecimal;

import org.junit.BeforeClass;
import org.junit.Test;

public class TemperatureTest {
	private static Temperature testTemperature;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		testTemperature = new Temperature(20,TemperatureScale.CELCIUS);
	}
	
	@Test
	public final void defaultConstructor_SingleCase() {
		Temperature newTemperature = new Temperature(new BigDecimal("55.14"),TemperatureScale.CELCIUS); 
		assertEquals(new BigDecimal("55.14"), newTemperature.getValue());
		assertEquals(TemperatureScale.CELCIUS, newTemperature.getTemperatureScale());
	}
	
	@Test
	public final void integerConstructor_SingleCase() {
		Temperature newTemperature = new Temperature(new BigDecimal("50"),TemperatureScale.CELCIUS); 
		assertEquals(new BigDecimal("50"), newTemperature.getValue());
		assertEquals(TemperatureScale.CELCIUS, newTemperature.getTemperatureScale());
	}
	
	@Test
	public final void isValidValue_TrueCase(){
		
		assertTrue(Temperature.isValidValue(new BigDecimal("100.00")));
	}
	
	@Test
	public final void isValidValue_FalseCase(){
		assertFalse(Temperature.isValidValue(null));
	}
	
	@Test
	public final void toTemperatureScale_SingleCase(){
		Temperature convertedTemperature = testTemperature.toTemperatureScale(TemperatureScale.KELVIN);
		assertEquals(convertedTemperature.getValue(),new BigDecimal("293.15"));
		assertEquals(convertedTemperature.getTemperatureScale(),TemperatureScale.KELVIN);
	}
	
	@Test
	public final void isValidScale_TrueCase(){
		assertTrue(Temperature.isValidTemperatureScale(TemperatureScale.KELVIN));
	}
	
	@Test
	public final void isValidScale_FalseCase(){
		assertFalse(Temperature.isValidTemperatureScale(null));
	}
}
